<!-- 车辆审批情况 -->
<template>
	<view>
		<block v-if="item.state!='0'">
			<ApproveDetail :item="itemData"></ApproveDetail>
		</block>
		<!-- 当前预约审批状态为  0：未审核 && 当前平台用户为审批人（园区管理员） -->
		<block v-if="item.state=='0'&&(!!webUserInfo) && (!!webUserInfo.job)&& webUserInfo.job.includes(1)">
			<ApproveHandle :item="itemData"></ApproveHandle>
		</block>
	</view>
</template>

<script>
	import ApproveDetail from "@/pages/approve/components/car/approve-detail.vue"
	import ApproveHandle from "@/pages/approve/components/car/approve-handle.vue"
	import {
		Platform,
		Storage_Key
	} from '@/static/config.js';
	import {
		GetRecordState,
		GetApproveState
	} from "@/common/util.js"
	export default {
		props: ['item'],
		components: {
			ApproveDetail,
			ApproveHandle
		},
		computed: {
			// wxUserInfo() {
			// 	return this.$storage.get(Storage_Key.user_info, true);
			// },
			webUserInfo() {
				return this.$storage.get(Storage_Key.web_user_info, true);
			},
		},
		data() {
			return {
				itemData: {},
			}
		},
		mounted() {
			this.itemData.carid = this.item.id; // 车辆ID -- approve-handle用
			this.itemData.state = this.item.state; // 车辆审批状态（因为车辆审批表没有此字段） -- approve-detail用
			console.log(this.itemData)
			this.loadData();
		},
		methods: {
			// 获取审批详情 by 预约ID
			loadData() {
				let _self = this;
				let totalcount = -1;
				uni.request({
					url: Platform.api_requestUrl + '/stp-car-approval/GetListDetail',
					data: {
						carid: _self.item.id,
						pageIndex: 1,
						pageSize: 100000000,
					},
					header: {},
					method: 'GET',
					success: (res) => {
						if (res.data.code == 200 && !!res.data.data.length != 0) {
							_self.itemData = {
								..._self.itemData,
								...res.data.data[0]
							};
						}
					},
					complete: () => {
						console.log("complete")
					},
					fail: (error) => {
						console.log("fail")
					},
				});
			},
		}
	}
</script>

<style lang='scss' scoped>

</style>
